import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../../provider/model.dart';
import '../../../config/theme.dart';
import './sequence.dart';

/// 需要在Widget的父层Widget去设置局部Theme，才会生效；
/// 如果我们直接在局部Theme的child 属性指定的Widget中去使用的话，会拿到系统的全局Theme；

class ExamTheme extends StatefulWidget {
  @override
  _ExamThemeState createState() => _ExamThemeState();
}

class _ExamThemeState extends State<ExamTheme> {
  @override
  Widget build(BuildContext context) {
    return Consumer<ExamTopicModel>(
      builder: (context, etm, child) {
        return Theme(
          data: etm.et == 0 ? lightTheme : darkTheme,
          isMaterialAppTheme: true,
          child: SequenceExam()
        );
      },
    );
  }
}